package com.ruoyi.controller;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.service.AlyService;
import com.ruoyi.utils.ALYMessageUtils;
import com.ruoyi.utils.SimpleResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("/aly")
public class AlyController {
    @Autowired
    @Resource
    private AlyService alyService;

    /**
     * 阿里云 发送验证码 服务
     * @param request
     * @param phoneNumber
     * @return {@code SimpleResult}
     */
    @GetMapping("/getCode/{phoneNumber}")
    public SimpleResult getCode(HttpServletRequest request, @PathVariable String phoneNumber) {
        final boolean isOk = alyService.sendCode(phoneNumber);
        if (isOk) {
            return SimpleResult.success("发送短信完成, 请注意接收~");
        } else {
            return SimpleResult.error("发送短信失败, 请检查手机号是否正确~");
        }
    }

}
